package com.example.group_20.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.group_20.entity.Category;
import com.example.group_20.entity.FilesInfor;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author: 栋
 * @data: 2023/8/11
 * @descriptions:
 */
@Mapper
public interface FilesMapper extends BaseMapper<FilesInfor> {
    @Select("select * from files")
    public List<FilesInfor> findAll();

    @Select("select * from files where file_id=#{file_id}")
    public FilesInfor findById(String file_id);

    @Select("select * from files where status!=-1")
    public List<FilesInfor> findAllSub();

    @Select("select * from files where group_id=#{group_id} and status!=-1")
    public List<FilesInfor> findByGroup(int group_id);

    @Select("select * from files where group_id=#{group_id} and type=#{category} and status!=-1")
    public List<FilesInfor> findByGroupAndCategory(int group_id,int category);

    @Update("update files set status=-1 where file_id=#{file_id}")
    public int deleteById(String file_id);

    @Update("update files set teacher_id=#{teacher_id},teacher_name=#{teacher_name},check_date=#{check_date},check_time=#{check_time},comments=#{comments},status=#{status} where file_id=#{file_id}")
    public int updateFile(FilesInfor filesInfor);

    @Update("update files set group_id=group_id-1 where group_id>#{group_id}")
    public int updateFilesGroupId(int group_id);


}
